﻿#pragma once

#include "../../Shared/Packet.h"
#include <vector>
#include <stdexcept>
#include <any>
#include "exceptionhelper.h"

using namespace Client::MirControls;
namespace C = ClientPackets;


namespace Client::MirNetwork
{
    class Network final
    {
    private:
        static TcpClient *_client;
    public:
        static int ConnectAttempt;
        static bool Connected;
        static long long TimeOutTime;
        static long long TimeConnected;

    private:
        static ConcurrentQueue<Packet*> *_receiveList;
        static ConcurrentQueue<Packet*> *_sendList;

        static std::vector<unsigned char> _rawData;
        static const std::vector<unsigned char> _rawBytes;

    public:
        static void Connect();

    private:
        static void Connection(IAsyncResult *result);

        static void BeginReceive();
        static void ReceiveData(IAsyncResult *result);

        static void BeginSend(std::vector<unsigned char> &data);
        static void SendData(IAsyncResult *result);


    public:
        static void Disconnect();

        static void Process();

        static void Enqueue(Packet *p);
    };
}
